package com.middlegroup.common.enums;


import org.apache.commons.lang3.StringUtils;

/**
 * 自定义错误码
 *
 * @author pc
 */
public enum PaypalResponseCode {

    /**
     * 新建
     */
    created("created", 0),

    /**
     * 成功
     */
    approved("approved", 1),
    /**
     * 成功
     */
    completed("completed", 1),
    /**
     * 退款回调成功
     */
    Refunded("Refunded", 1),
    /**
     * 支付回调成功
     */
    Completed("Completed", 1),
    /**
     * 失败
     */
    failed("failed", 2);
    private String code;
    private Integer status;

    public String code() {
        return code;
    }

    public Integer status() {
        return status;
    }

    PaypalResponseCode(String code, Integer status) {
        this.code = code;
        this.status = status;
    }
    /**
     * 根据code获取name
     * @param code
     * @return
     */
    public static Integer getStatus(String code) {
        for (PaypalResponseCode e : PaypalResponseCode.values()) {
            if (StringUtils.equals(e.code(),code)) {
                return e.status;
            }
        }
        return null;
    }

}